package hot;

public class Num538 {
    int sum = 0;
    public TreeNode convertBST(TreeNode root) {
        dfs(root);
        return root;
    }
    public void dfs(TreeNode root) {
        if(root == null) return;
        dfs(root.right);
        int temp = sum;
        sum += root.val;
        root.val += temp;
        dfs(root.left);
    }
}
